<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>收货地址</title>
     <meta name="format-detection" content="telephone=no">
    <meta name="viewport" content="minimal-ui,width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link href="__PUBLIC__/wap/css/rest.css"  rel="stylesheet">
    <link href="__PUBLIC__/wap/css/user.css"  rel="stylesheet">
    <link href="__PUBLIC__/wap/css/product.css"  rel="stylesheet">
    <link rel="stylesheet" href="__PUBLIC__/wap/css/tip.css" >
</head>
<body id="u-body">
     <!--绑定头部-->    
 <include file="Public/binding_head"/>
    <!--绑定头部-->

    <header id="header" class="u-header clearfix">
        <div class="u-hd-left f-left">
            <a href="javascript:history.go(-1);" class="J_backToPrev"><span class="u-icon-px i-hd-back"></span></a>
        </div>
        <div class="u-hd-tit"><span>收货地址</span></div>
    </header>
    <form action="" role="form" id="form2" novalidate="novalidate" method="post" onSubmit="return false;">  
    <div class="ui-form ui-border-b">
        <div class="ui-form-item ui-border-b">
            <label>收货人</label>
            <input name="consignee" id="consignee" type="text" value="{$data.consignee}">
        </div>
        <div class="ui-form-item ui-border-b">
            <label>手机号码</label>
            <input name="mobile" id="mobile" type="text" value="{$data.mobile}">
        </div>
       <div class="ui-form-item">
            <label>省份</label>
            <div class="ui-select ui-border-bi disabled">
                <select  id="province" name="province" class="city_p" {$disable} onchange="choice_province('city')" emptymsg="请选择省" datatype="*">
                    <option value="0">请选择</option>
                    <volist name="citylist['province']" id="vo">
                    <option value="{$vo.cityid}"  <if condition="$data['province']==$vo['cityid']">selected</if> >{$vo.cityname}</option>
                    </volist>    
                </select>
            </div>
        </div>
        <div class="ui-form-item ">
            <label>城市</label>
            <div class="ui-select ui-border-bi disabled">
                <select id="city" name="city" class="city_c" {$disable} onchange="choice_city('city')" emptymsg="请选择市" datatype="*" >
                     <option value="0">请选择</option>
                      <volist name="citylist['city']" id="vo">
                    <option value="{$vo.cityid}"  <if condition="$data['city']==$vo['cityid']">selected</if> >{$vo.cityname}</option>
                    </volist>    
                </select>
            </div>
        </div>
        <div class="ui-form-item ">
            <label>区县</label>
            <div class="ui-select ui-border-bi disabled">
                <select id="area" name="area" class="city_a" {$disable} emptymsg="请选择区" datatype="*">
                     <option value="0">请选择</option>
                       <volist name="citylist['area']" id="vo">
                    <option value="{$vo.cityid}"  <if condition="$data['area']==$vo['cityid']">selected</if> >{$vo.cityname}</option>
                    </volist> 
                </select>
            </div>
        </div>
        <div class="ui-form-item ui-border-bi ">
            <label>详细地址</label>
            <textarea  name="address" id="address" rows="5" emptymsg="请填写详细地址" datatype="*">{$data.address}</textarea>
        </div>
         <div class="ui-form-item ui-border-b">
            <label>邮编</label>
            <input name="zipcode" id="zipcode" type="text" value="{$data.zipcode}">
        </div>
          <div class="ui-form-item ui-border-b">
            <label>标志性建筑</label>
            <input name="sign_building" id="sign_building" type="text" value="{$data.sign_building}">
        </div>
        <div class="ui-form-item ui-border-b">
            <label>最佳送货时间</label>
            <input name="best_time" id="best_time" type="text" value="{$data.best_time}">
        </div>

        <!-- 加默认地址按钮star-->
          <div class="remember_login" style="padding:10px 10px;">
            <input id="touchweb_form-checkbox" name="is_default" type="checkbox"   {$data['is_default']?'checked':''}>
            <label for="touchweb_form-checkbox" style="font-size: 14px;">设置为默认地址</label>
            <a href="###" class="forgot_password"></a>
        </div>
          
    <input name="address_id"  type="hidden" value="{$data.address_id}">
    <input name="type"  type="hidden" value="{$_GET['type']}">
    <input name="cart_id"  type="hidden" value="{$_GET['cart_id']}">
    <input name="discount"  type="hidden" value="{$_GET['discount']}">
        <input name="order_id"  type="hidden" value="{$_GET['order_id']}">
        <input name="uri"  type="hidden" value="{$_GET['uri']}">
    
    <input name="draw_log_id"  type="hidden" value="{$_GET['draw_log_id']}">
    
    </div>

  </form>
    <a href="javascript:void(0);" class="new-abtn-type new-mg-tb30 phone_log_btn">确认提交</a>
 <div style="height:50px;">
   </div> 
     <!--end top-->
   <include file="Public/footer" />

   <include file="Public/wap_javascript" />
     <!--微信分享-->    
 <include file="Public/share_weixin" />
 



 <script type="text/javascript">
   var  binding_is_check=0;// 重复再次弹出 1是 0否
   var  binding_page='address_add';// //当前页面名称 不可重复
</script>  
         <!--绑定-->    
 <include file="Public/binding_phone"/>
    <!--绑定-->
 
    <script>
    var get_city_url="{:U('wap/index/get_city')}";
    </script>   
     <script src="__PUBLIC__/js/common.js"></script>
     <!--<script type="text/javascript" src="__PUBLIC__/layer/layer.js"></script> -->
        <script>

jQuery(document).ready(function() {
                //FormValidator.init();
jQuery.validator.addMethod("byteRangeLength", function(value) {
    var areaid=$("#area").val();
    var cityid=$("#city").val();
    var provinceid=$("#province").val();
    var ret=false;
    if(areaid>0 && cityid>0 && provinceid>0){
       ret=true;
    }
  return ret;   
});
jQuery.validator.addMethod ("checkType",function(value){
    var re =/^[\u4e00-\u9fa5]*$/.test($("#consignee").val());
    var ret = false;
    if(re){
        ret = true;
    }
    return ret;
});

$("#form2").validate({

   rules: {
   consignee:{
     required:true,
       checkType:true
   },
   mobile:{
       required:true,
       number:true,
       minlength:11,
       maxlength:11

   },
   area: 'byteRangeLength',
   address:'required'
  },
  messages: {
       consignee:{
           required:'<span class="icon-warning icon_warning"></span>&nbsp;请输入收货人姓名',
           checkType:'<span class="icon-warning icon_warning"></span>&nbsp;用户名只能输入中文'
       },
       mobile:{
        required:'<span class="icon-warning icon_warning"></span>&nbsp;请输入手机号码',
       number:'<span class="icon-warning icon_warning"></span>&nbsp;请输入正确的手机号码',
       minlength:'<span class="icon-warning icon_warning"></span>&nbsp;请输入正确的手机号码',
       maxlength:'<span class="icon-warning icon_warning"></span>&nbsp;请输入正确的手机号码'
       },
       area: '<span class="icon-warning icon_warning"></span>&nbsp;请选择完整的省市区',
       address:'<span class="icon-warning icon_warning"></span>&nbsp;请输入详细地址'
  },
   focusInvalid:false,
  success: function(label) { 
            // set  as text for IE 
           // alert('ok'); 
            //label.html(" ").addClass("checked"); 
        }, 
        /*执行ajaxsubmit  */ 
        submitHandler: function(editform) { 

            var options = { 
                url :  "<?php echo U('Wap/Address/set_address'); ?>", 
                type : "post" , 
                dataType:'json', 
                target : "#loader", 
                error: function(){layer.msg("服务器没有返回数据，可能服务器忙，请重试",{icon:5});}, 
                onwait : "正在处理信息，请稍候...",
                success: function(response){ 
                       console.log(response);
                    //$("#loader").fadeIn(500).html(response.data).fadeOut(500); 
                    //$('#editform').hide(2000); 
                    if(response.status==1){
                        //alert("操作成功");
                       window.location.href=response.return_url;//; 
                    }else{
                        layer.msg(response.error,{icon:5});
                    }
                }
            };
            setTimeout((function(opt){
                return function(){
                    $('#form2').ajaxSubmit(opt);
                }
            })(options), 300); 
            return false; 
        }

  });

$('.phone_log_btn').click(function(){
    $('#form2').submit();
});


$('.send_sms').click(function(){
    var is_send=$(this).hasClass('disable');
    if(is_send){
      return false;
    }else{
        //短信发送
         $.ajax({
            url: "{:U('Wap/Login/send_sms')}",
            type: "get",
            dataType: "json",
            data: {
                mobile: function () {
                    return $("#mobile").val();　　　　//这个是取要验证的数据
                },
                verify_code: function () {
                    return $("#verify_code").val();　　　　//这个是取要验证的数据
                }
            },
            success: function (msg) {　　　　//判断控制器返回的内容
                if (msg.status == "1") {
                     //disable
                     $('#mobile_code').val(msg.code);
                     run_time_out();
                }else {
                    //alert(msg.msg);
                    layer.msg(msg.msg, {icon: 5}); 
                }
            }
       });
    }
});


});

</script>  
</body>
</html>